package com.heeexy.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.heeexy.example.service.ThingService;
import com.heeexy.example.util.CommonUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/thing")

public class ThingController {

    @Autowired
    private ThingService thingService;

    @PostMapping("/listThing")
    public JSONObject listThing(@RequestBody JSONObject requestJson) {
        CommonUtil.hasAllRequired(requestJson, "nickName");
        return thingService.listThing(requestJson);
    }


    @PostMapping("/addThing")
    public JSONObject addThing(@RequestBody JSONObject requestJson) {
        CommonUtil.hasAllRequired(requestJson,
                "title,content");
        return thingService.addThing(requestJson);
    }





}
